import { message } from 'antd'

export async function request (url: string, data: any) {
  const params = {
    method: 'POST',
    headers: {
      'Content-Type': 'application/json'
    },
    body: JSON.stringify(data)
  }

  try {
    const result = await fetch(url, params)
    return result.json()
  } catch(err) {
    console.log(err);
    message.error("请求出错了");
    return null
  }
}